#include <iostream>
#include <vector>
using namespace std;

template<typename T>
void quick_sort(vector<T> &my_vector, int low, int high);

int main(int argc, char const *argv[]){
    //initial my_vector
    int my_array[10] = {1, 9, 45, 7, 15, -5, 2, 74, -27, 10};
    int my_array_length = sizeof(my_array)/sizeof(my_array[0]);
    vector<int> my_vector(my_array, my_array + my_array_length); 

    quick_sort(my_vector, 0, my_vector.size()-1);
    for (int i = 0; i < my_vector.size(); i++)
        cout << my_vector[i] << ' ';
    cout << endl;
    return 0;
}

template<typename T>
void quick_sort(vector<T> &my_vector, int low, int high){
    if(low < high){
        int left = low, right = high;
        T pivot = my_vector[low];
        while(left < right){
            while(left < right && my_vector[right] >= pivot)
                right--;
            if(left < right)
                my_vector[left++] = my_vector[right];
            while(left < right && my_vector[left] < pivot)
                left++;
            if(left < right)
                my_vector[right--] = my_vector[left];
        }
        my_vector[left] = pivot;
        quick_sort(my_vector, low, left-1);
        quick_sort(my_vector, right+1, high);
    }
}
